﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Print_Print2g : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Phuluc2gPirnt"] != null)
        {
            lblSummary.Text = Session["Phuluc2gPirnt"].ToString();
            try
            {
                Response.Clear();
                Response.AddHeader("content-disposition", "attachment; filename=FileName.xls");
                Response.Charset = "";
                Response.ContentType = "application/vnd.xls";
                System.IO.StringWriter stringWrite = new System.IO.StringWriter();
                System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
                grid_Detail.RenderControl(htmlWrite);
                Response.Write(stringWrite.ToString());
                Response.End();
                Response.Redirect("javascript:window.close()");
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('" + ex.Message + "')</script>");
            }
            Session.Remove("Phuluc2gPirnt");
        }
    }
}